<?php

namespace App\Http\Controllers\Api\v1;


use App\common;
use App\Logic\RegisterLogic;
use Illuminate\Http\Request;

class Register
{

    /**
     * 授权方法
     * @param Request $request
     * @throws \Exception
     */
    public function registerIndex(Request $request)
    {
        try {
            $code = $request->post('code');
            $nickName = $request->post('nickName');
            $avatarUrl = $request->post('avatarUrl');
            if (empty($code) && empty($nickName) && empty($avatarUrl)) throw new \Exception('参数不能为空');
            $RegisterDosFunction = RegisterLogic::indexFunction($code, $nickName, $avatarUrl);
            if ($RegisterDosFunction) throw new \Exception('授权成功');
            throw new \Exception('授权失败');
        } catch (\Exception $exception) {
            return common::fail('', "", $exception->getMessage());
        }
    }

}
